package com.snda.lib.task;

import java.util.HashMap;
import java.util.Map;
import com.snda.lib.http.HttpUtil;
import com.snda.lib.http.ICallBack;
import android.content.Context;

// 上传二进制数据流
public class HttpUploadStreamTask extends HttpAnsycTask {

	protected byte[] byteData; // 需要上传的二进制数据

	public HttpUploadStreamTask(Context context, ICallBack callback) {
		super(context, callback);
	}

	public void setUploadData(byte[] data) {
		byteData = data;
	}

	@Override
	protected Map<String, Object> doHttpRequest() {

		Map<String, Object> map = new HashMap<String, Object>();
		map = httpRequest.doStreamPostRequest(strUrl, byteData);
		return map;
	}

	protected Map<String, Object> parseResponse(String strResponse) {
		return null;
	}

	protected Map<String, Object> process(Map<String, Object> map) {

		Map<String, Object> mapData = checkResponse(map);
		Integer nError = (Integer) map.get(HttpUtil.KEY_ERROR_CODE);
		if (nError != HttpUtil.ERROR_SUCCESS)
			return mapData;

		String strResponse = (String) map.get(HttpUtil.KEY_CONTENT);
		return parseResponse(strResponse);
	}

}